<?php
/*
 *模型类
 */
/* class model{
 //成员属性$db,用来保存数据库操作类的实例
 protected $db;
 protected $tableName;	//表名
 protected $fields;		//查询字段(查询使用)
 
 //构造方法,用来获取数据库连接资源
 public function __construct(){
 //实例化数据库
 $this->db = MySqlDb::getMySqlDb($GLOBALS, ['dbConfig']);
 }
 
 public function __construct($tableName){
 //实例化数据库
 $this->db = MySqlDb::getMySqlDb($GLOBALS, ['dbConfig']);
 //获取表名
 $this->tableName = $tableName;
 }
 
 //指定待查询字段
 public function field($fields){
 $this->fields = $fields;
 return $this;
 }
 
 //解析字段(查询用)
 //将$this->fields转换成为逗号拼接的字符串
 private function parseFields(){
 
 if(is_string($this->fields)){
 $this->fields = explode(',', $this->fields);
 }
 
 foreach($this->fields as $key => $value){
 $this->fields[$key] = "`value`";
 }
 return implode(',', $this->fields);
 }
 
 //查询数据
 //如果没有指定$this->fields,则查询所有字段
 public function select(){
 //拼接sql语句
 if(empty($this->fields)){
 $sql = "select * from $this->tableName";
 } else{
 $fields = $this->parseFields();
 $sql = "select $fields from $this->tableName";
 }
 //清除本次的字段
 $this->fields = null;
 return $this->db->fetchAll($sql);
 }
 } */
?>